package com.hotel.front;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.Util;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.gson.Gson;
import com.hotel.BL.*;

import data.*;
import data.passingData.ResultData;

@SuppressWarnings("serial")
public class HotelCustomSettingService extends HttpServlet {
	protected static DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
	throws IOException {
		String func = req.getParameter("func");
		try{
			if(func.equals("getHotelCustomSetting"))
				GetHotelCustomSetting(req,resp);
			else if(func.equals("getHotelCustomSetting"))
				GetHotelCustomSetting(req,resp);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void GetHotelCustomSetting(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		Gson gson = new Gson();
		String sessionCheck = Util.checkSessionEntity(req,resp);
		if(sessionCheck==null||sessionCheck.equals("")){
			resp.setContentType("text/plain; charset=UTF-8");
			resp.getWriter().println(gson.toJson(new ResultData(false)));
			return;
		}
		HttpSession session = req.getSession(true);
		long hotelId = (Long) session.getAttribute("hotelId");
		List<HotelCustomSetting> obj = new HotelCustomSettingLogic().GetHotelCustomSettingAll(hotelId);
		resp.setContentType("text/plain; charset=UTF-8");
		resp.getWriter().println(gson.toJson(obj));
	}
}
